<?php
	include_once("conn.php");

	$board_name = $_POST["board_name"];
	$board_admin = $_POST["board_admin"];
	$board_msg = $_POST["board_msg"];

	$sql = "select * from bbs_user where u_name = '".$board_admin."'";
	$result = mysql_query($sql);
	$q_result = mysql_fetch_array($result);
	if(!$q_result["u_id"])
	{	
		echo "该用户不存在！";	
		echo "<script>window.history.back();</script>";
	}
	else {
			$board_admin_id = $q_result["u_id"];				//取得版主在bbs_user表中的u_id;

			$sql = "insert into bbs_session(s_name,s_admin_id,s_profile,s_admin_name) values('".$board_name."','".$board_admin_id."','".$board_msg."','".$board_admin."')";
			$result = mysql_query($sql);
			if($result)
			{
				echo "创建版面成功!<br />";
				echo "您创建的版面名为：".$board_name."<br />";
				echo "该版面的版主为：".$board_admin;
				echo "<br />";
				echo "<a href= 'index.php'>返回首页</a>&nbsp&nbsp";
				echo "<a href = 'create_board.php'>返回继续创建版面</a>";
			}
			else 
			{
				echo "创建版面失败";
			}
	}
?>